import { useState } from 'react';

import { useAuth } from '@/hooks/useAuth';

const login = () => {
  const [username, setUsername] = useState('');
  const [password, setPassword] = useState('');

  const { login } = useAuth();

  const handleLogin = () => login(username, password);

  return (
    <div>
      <h1>Login</h1>
      <div>
        <input
          type="text"
          placeholder="用户名"
          value={username}
          onChange={(evt) => setUsername(evt.target.value)}
        />
      </div>
      <div>
        <input
          type="password"
          placeholder="密码"
          value={password}
          onChange={(evt) => setPassword(evt.target.value)}
        />
      </div>
      <button type="button" onClick={handleLogin}>
        登录
      </button>
    </div>
  );
};

export default login;
